import 'package:flutter/material.dart';

/// @class : custom_floating_button
/// @date : 2023-02-22 19:41
/// @name : LFC
/// @description : flutter 重写FloatingActionButtonLocation 自定义位置
// 1.继承 FloatingActionButtonLocation
// 2.增加 offsetX、offsetY 两个变量
// 3.重写getOffset 并通过父类”FloatingActionButtonLocation“ 调用 Offset offset = location.getOffset(scaffoldGeometry);获取到设置完location 之后的位置对其进行修改
//https://blog.csdn.net/Luo_ios_boke/article/details/124747322
class FloatingButtonCustomLocation extends FloatingActionButtonLocation  {
  FloatingActionButtonLocation location;
  final double offsetX;    // X方向的偏移量
  final double offsetY;    // Y方向的偏移量
  FloatingButtonCustomLocation(this.location,{this.offsetX = 0, this.offsetY = 0});

  @override
  Offset getOffset(ScaffoldPrelayoutGeometry scaffoldGeometry) {
    Offset offset = location.getOffset(scaffoldGeometry);
    return Offset(offset.dx + offsetX, offset.dy + offsetY);
  }


  @override
  Animation<double> getRotationAnimation({required Animation<double> parent}) {
    return Tween<double>(begin: 1.0, end: 1.0).animate(parent);
  }

  @override
  Animation<double> getScaleAnimation({required Animation<double> parent}) {
    return Tween<double>(begin: 1.0, end: 1.0).animate(parent);
  }
}

// // 调用方法
// FloatingButtonCustomLocation(
// FloatingActionButtonLocation.centerDocked,
// offsetY: Platform.isIOS && padding.bottom > 0 ? 15 :  -10,
// offsetX: 0
// )
// 注:offsetY或offsetX 可选参数 默认 = 0
